package cn.edu.hznu.coursework.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table
@DynamicUpdate(true)
public class Course extends AbstractIndentifiedEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7004370614911583890L;
	
	@Column
	private char courseNo;
	
	@Column
	private String courseName;

	@ManyToOne(fetch = FetchType.LAZY)
	private Teacher teacher;
	
	@ManyToMany(targetEntity = Student.class, fetch = FetchType.LAZY, mappedBy = "courses")
	private List<Student> students;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "course", orphanRemoval = true)
	private List<StudentWork> studentWorks;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "course", orphanRemoval = true)
	private List<TeacherWork> teacherWorks;

	public char getCourseNo() {
		return courseNo;
	}

	public void setCourseNo(char courseNo) {
		this.courseNo = courseNo;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

	public List<StudentWork> getStudentWorks() {
		return studentWorks;
	}

	public void setStudentWorks(List<StudentWork> studentWorks) {
		this.studentWorks = studentWorks;
	}

	public List<TeacherWork> getTeacherWorks() {
		return teacherWorks;
	}

	public void setTeacherWorks(List<TeacherWork> teacherWorks) {
		this.teacherWorks = teacherWorks;
	}
	
}
